import cv2

src = cv2.imread('assets/img/0.jpg')
cv2.imshow('img', src)

# 将图片灰度转换
gray_img = cv2.cvtColor(src, code=cv2.COLOR_BGR2GRAY)
cv2.imshow('gray', gray_img)
cv2.waitKey(0)
cv2.destroyAllWindows()

# 保存图片
# cv2.imwrite('gray.jpg', gray_img)